<?php

/**
 * @author Du Dan
 * @copyright 2013
 */

class EventPopular extends CWidget
{
    public function init()
    {
        parent::init();
    }

    public function run()
	{
		$criteria = new CDbCriteria();
		$criteria->condition = 'status="A" AND DATE(startdate) >= NOW()';
		$criteria->limit = 5;
		$criteria->order = 'numviews DESC, startdate ASC,enddate ASC';
		
		$model = Events::model()->findAll($criteria);
    	$this->render('eventPopular', array(
			'model'=>$model
		));
    }
}

?>